module.exports = {
    db : function(){
        this.dao = require('mysql'); //Data Access Object
        this.instance;
        this.results = false;
        
        this.init = function(){
            this.instance = this.dao.createConnection({
                host: config.db_host,
                port: config.db_port,
                user: config.db_user,
                password: config.db_password,
                database: config.db_name,
            });
            this.instance.connect();
        };
        
        this.query = function(sql){
            var query = main.db.instance.query(sql);
            query.on('error', function(err){ throw err; });
            return query;
        };
    }
}